package com.inossem.warehousestorage_inossem.adapter.storage;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.inossem.warehousestorage_inossem.R;
import com.inossem.warehousestorage_inossem.bean.up_frame.UpFrameItemBean;
import com.inossem.warehousestorage_inossem.dialog.DialogUtils;

import java.util.List;


/**
 * Created by cjz on 2017/6/6.
 */

public class UpItemAdapter extends BaseAdapter {

    private Context mContext;
    private List<UpFrameItemBean.DataBean.ListBean> list;
    private LayoutInflater inflater;

    public UpItemAdapter(Context context, List<UpFrameItemBean.DataBean.ListBean> list) {
        mContext = context;
        this.list = list;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list==null?0:list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        UpFrameItemBean.DataBean.ListBean item = (UpFrameItemBean.DataBean.ListBean) getItem(position);
        ViewHolder viewHolder;
        if (convertView == null || (convertView != null && convertView.getTag() == null)) {
            convertView = inflater.inflate(R.layout.view_storage_manage_matr_up_list, null);
            viewHolder = new ViewHolder();
            //初始化控件
            initView(viewHolder, convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        //初始化数据
        initData(mContext, viewHolder, convertView, item);

        return convertView;
    }

    private void initView(ViewHolder viewHolder, View view) {
        viewHolder.postion = (TextView) view.findViewById(R.id.postion);


    }

    private void initData(Context context, ViewHolder viewHolder, View view, UpFrameItemBean.DataBean.ListBean item) {
        viewHolder.postion.setText(item.getPosition());


    }

    private class ViewHolder {
        private TextView  postion;
    }

    public void setList(List<UpFrameItemBean.DataBean.ListBean> list) {
        this.list = list;
    }
}
